package main.java.com.study.动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
 
 
public class Main1 {
    public static void main(String[] args) {
        UserService userService = new UserServiceImpl();
        InvocationHandler invocationHandler = new MyInvocationHandler(userService);

//        System.out.println(userService.getName(1));


        UserService userServiceProxy = (UserService)Proxy.newProxyInstance(userService.getClass().getClassLoader(),
                userService.getClass().getInterfaces(), invocationHandler);

        System.out.println(userServiceProxy.getName(1));
        System.out.println(userServiceProxy.getTEST("辛稼轩"));
        System.out.println(userServiceProxy.getAge(1));
    }
}